home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / sframework / plugins / Camera.vbs < prev    next >
Encoding:
Text File  |  2004-09-09  |  4.6 KB  |  135 lines

  1. 'FMA Script Framework Plugin
  2. 'Camera
  3. 'Control your phones camera from your computer
  4.  
  5. 'TODO:
  6. '-wait for an fma internal sleep function that only blocks the script and not fma
  7. '-loop
  8.  
  9. Class Camera
  10.     
  11.     Private m_Self
  12.     Private mainMenu
  13.     
  14.     'Some info about the plugin
  15.     Public Property Get SHOWABLE 'Do I have a menu?
  16.         SHOWABLE    = True
  17.     End Property
  18.     Public Property Get TITLE 'What's my name?
  19.         TITLE       = "Camera"
  20.     End Property
  21.     Public Property Get DESCRIPTION 'What's my purpose?
  22.         DESCRIPTION = "Control your phones camera from your computer"
  23.     End Property
  24.     Public Property Get AUTHOR 'Who created me?
  25.         AUTHOR      = "streawkceur (inspired by hrs)"
  26.     End Property
  27.     Public Property Get URL 'Were can I be found? Where can you get more information?
  28.         URL = "http://fma.xinium.com/"
  29.     End Property
  30.     
  31.     'Who am I?
  32.     Public Property Let Self (s)
  33.         m_Self = s
  34.         ' Some init stuff here:
  35.         Set List = New LinkedList
  36.         Dim bi
  37.         bi = List.BackInserter
  38.         bi.Item = Array( "Help",          s & ".Help" )
  39.         bi.Item = Array( "Shot & Return", s & ".ShotAndReturn" )
  40.         bi.Item = Array( "Shot",          s & ".Shot" )
  41.         Set mainMenu = New ManagedMenu
  42.         mainMenu.Title = TITLE
  43.         mainMenu.SetList List
  44.         EventManager.RegisterEvent "Connected", s & ".Init", Me
  45.         If IsEmpty(Settings(Me, "OutputDirectory")) Or Trim(Settings(Me, "OutputDirectory")) = "" Then Settings(Me, "OutputDirectory") = "C:\"
  46.         If IsEmpty(Settings(Me, "InputFilename"))   Or Trim(Settings(Me, "InputFilename"))   = "" Then Settings(Me, "InputFilename")   = "/Pictures/Image(1).jpg"
  47.     End Property
  48.     Public Property Get Self
  49.         Self = m_Self
  50.     End Property
  51.     
  52.     Sub Show()
  53.         mainMenu.ShowMenu
  54.     End Sub
  55.     
  56.     Sub Init()
  57.         fma.AddCmd "Take a picture", m_Self & ".Shot"
  58.         fma.AddCmd "blub", m_Self & ".blub"
  59.     End Sub
  60.     
  61.     Sub Help
  62.         EmptyMenu.ShowMenu
  63.         am.DlgInformation "Camera", "To use the camera feature use the entries in the FMA Tools menu."
  64.     End Sub
  65.     
  66.     Sub ShotAndReturn
  67.         Shot 'Take picture
  68.         If PluginManager.IsLoaded("AutoMenu") Then    PluginManager("AutoMenu").GoToMenu 'Return to accessories menu
  69.     End Sub
  70.     
  71.     Sub Shot()
  72.         If IsEmpty(Settings(Me, "OutputDirectory")) Or Trim(Settings(Me, "OutputDirectory")) = "" Then
  73.             Debug.ErrorMsg "You must specify Camera->OutputDirectory in the configurator!"
  74.             Settings(Me, "OutputDirectory") = "C:\"
  75.             Exit Sub
  76.         End If
  77.         If Not Fso.FolderExists(Settings(Me, "OutputDirectory")) Then
  78.             Debug.ErrorMsg "Your specified Camera->OutputDirectory doesn't exist! Please create it or fix the setting!"
  79.             Exit Sub
  80.         End If
  81.         If IsEmpty(Settings(Me, "InputFilename")) Or Trim(Settings(Me, "InputFilename")) = "" Then
  82.             Debug.ErrorMsg "You must specify Camera->InputFilename in the configurator!"
  83.             Settings(Me, "InputFilename") = "/Pictures/Image(1).jpg"
  84.             Exit Sub
  85.         End If
  86.         
  87.         Transmit "AT+CLCK=""CS"",0" ' Unlock phone
  88.         'AT+CKPD=<keys>[,<time>[,<pause>]]
  89.         Transmit "AT+CKPD="":R"",20" ' Go to standby screen
  90.         Transmit "AT+CLCK=""CS"",2" ' Request status to force transmission of previous command...
  91.         Util.Sleep 2200
  92.         Transmit "AT+CKPD="":C""" ' Enter camera mode
  93.         'Transmit "AT+CLCK=""CS"",2" ' Request status to force transmission of previous command...
  94.         Util.Sleep 500
  95.         Debug.DebugMsg "--------------> CAM"
  96.         Transmit "AT+CKPD="":C""" ' Take picture
  97.         Transmit "AT+CLCK=""CS"",2" ' Request status to force transmission of previous command...
  98.         
  99.         ' create filename here to get the (more or less) exact time & date of the picture
  100.         Dim outputFile
  101.         outputFile = Settings(Me, "OutputDirectory")
  102.         If Right(outputFile, 1) <> "\" Then outputFile = outputFile & "\"
  103.         outputFile = outputFile & "Phone-Camera (" & Year(Date) & "-" & LeadZero(Month(Date)) & "-" & LeadZero(Day(Date)) & ")-(" & LeadZero(Hour (time)) & "-" & LeadZero(Minute (time)) & "-" & LeadZero(Second (time)) & ").jpg"
  104.         
  105.         Util.Sleep 4000
  106.         Debug.DebugMsg "--------------> SHOT"
  107.         Transmit "AT+CKPD="":C""" ' Save picture
  108.         'Transmit "AT+CLCK=""CS"",2" ' Request status to force transmission of previous command...
  109.         Util.Sleep 2000
  110.         Debug.DebugMsg "--------------> SAVE"
  111.         Transmit "AT+CKPD="":R"",20" ' Go to standby screen
  112.         Transmit "AT+CLCK=""CS"",2" ' Request status to force transmission of previous command...
  113.         
  114.         fma.ObexCut outputfile, Settings(Me, "InputFilename")
  115.     End Sub
  116.     
  117.     Sub blub
  118.         fma.Debug "Before 0"
  119.         Transmit  "AT+CKPD=""0"""
  120.         fma.Debug "After 0"
  121.         'Util.Sleep 1000
  122.         fma.Debug "After Sleep"
  123.         fma.Debug "Before 1"
  124.         Transmit  "AT+CKPD=""1"""
  125.         fma.Debug "After 1"
  126.     End Sub
  127.     
  128.     Function LeadZero( ByVal N )
  129.         If (N>=0) and (N<10) Then LeadZero = "0" & N else LeadZero = "" & N
  130.     End Function
  131.     
  132. End Class
  133.  
  134.  
  135.